import 'package:dmz/utils/sp_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class RunMessageModel {
  int? accompany_days; //陪伴天数
  double? total_mileage; //累计里程
  double? max_ride_mileage; //单次最长里程
  double? accumulated_mileage; //15天累计里程
  double? max_speed; //最高时速
  double? avg_speed; //平均时速
  int? cycling_count; //骑行次数
  List<Map<String, dynamic>>? mileage_statics; //骑行次数
  int? maxNum;
  List<String> dateList = [];
  List<String> dateOtherList = [];

  getMaxdata() {
    double maxMileage = 0;
    if (mileage_statics != null) {
      for (var element in mileage_statics!) {
        if (element["mileage"] / 1000 > maxMileage) {
          maxMileage = element["mileage"] / 1000;
        }
      }

      if (maxMileage < 4) {
        maxMileage = 4;
      } else if (maxMileage > 4 && maxMileage < 8) {
        maxMileage = 8;
      } else if (maxMileage > 8 && maxMileage < 20) {
        maxMileage = 20;
      } else if (maxMileage > 20 && maxMileage < 40) {
        maxMileage = 40;
      } else if (maxMileage > 40 && maxMileage < 100) {
        maxMileage = 100;
      } else {
        maxMileage = 200;
      }
      maxNum = maxMileage.toInt();
    }
    debugPrint('最大里程 --- $maxNum');
    dateList = SPUtils.getDatesFromLastDays(15);
    dateOtherList = SPUtils.getDatesFromLastDays(15, attern: 'MM-dd');
    debugPrint('所有日期 $dateList');
  }
}
